// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-15 17:24
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.ACWing.DataTrains.addMinus;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        String s = myScanner.next(), t = myScanner.next();
        int n = s.length(), m = t.length();
        // builder就是一个栈
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < n; i++) {
            builder.append(s.charAt(i));
            if (builder.length() > m && builder.substring(builder.length() - m, builder.length()).equals(t)) {
                builder.delete(builder.length() - m, builder.length());
            }
        }
        System.out.println(builder.toString());
    }
}
